import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import index from '../components/index'
// 客户存酒仓
import customerGet from '../components/cunjiuFunc/customerGet'
import shoppingList from '../components/cunjiuFunc/shoppingList'
import drinkCardDetail from '../components/cunjiuFunc/drinkCardDetail'
import financialAudit from '../components/cunjiuFunc/financialAudit'
import saveList from '../components/cunjiuFunc/saveList'
import smsSearch from '../components/cunjiuFunc/smsSearch'
import audit from '../components/cunjiuFunc/audit'
import drinkCardView from '../components/cunjiuFunc/drinkCardView'
import print from '../components/cunjiuFunc/print'

// 充公酒
import confiscationIndex from '../components/chonggongFunc/confiscationIndex.vue'
import confiscationQuery from '../components/chonggongFunc/confiscationQuery.vue'
import confiscationSummary from '../components/chonggongFunc/confiscationSummary.vue'
import confiscationExamine from '../components/chonggongFunc/confiscationExamine.vue'
//公共模块


Vue.use(Router)

const router =  new Router({
  routes: [
    {
      path: '/login',
      name: 'Hello',
      component: login
    },
    {
      path: '/index',

      component: index
    },
    {
      path: '/cunjiuFunc/customerGet',

      component: customerGet
    },
    {
      path: '/cunjiuFunc/print',

      component: print
    },
    {
      path: '/cunjiuFunc/shoppingList',

      component: shoppingList
    },
    {
      path: '/cunjiuFunc/drinkCardDetail',

      component: drinkCardDetail
    },
    {
      path: '/cunjiuFunc/financialAudit',

      component: financialAudit
    },
    {
      path: '/cunjiuFunc/saveList',

      component: saveList
    },
    {
      path: '/cunjiuFunc/smsSearch',

      component: smsSearch
    }, {
      path: '/cunjiuFunc/audit',

      component: audit
    }, {
      path: '/cunjiuFunc/drinkCardView',

      component: drinkCardView
    },
    // 充公酒
    {
      path: '/chonggongFunc/confiscationIndex',

      component: confiscationIndex
    },
    {
      path: '/chonggongFunc/confiscationQuery',

      component: confiscationQuery
    },
    {
      path: '/chonggongFunc/confiscationSummary',

      component: confiscationSummary
    },
    {
      path: '/chonggongFunc/confiscationExamine',

      component: confiscationExamine
    },



  ]
})
router.beforeEach((to, from, next) => {
  
  if (to.path!="/login") {
    if (sessionStorage.userinfo) {
      next()
      
    }
    else{
      
      next({
        path: '/login'
      });
      
    }
  }else {
    next()
  }
})
export default router